#include "Calls.h"
#include <set>

Calls::Calls(){
	this->callsIndex = vector<pair<int, int>>();
}

int Calls::addCalls(int procIndex1, int procIndex2){
	if(procIndex1 < 0 || procIndex2 < 0){
		return -1;
	}
	this->callsIndex.push_back(make_pair(procIndex1, procIndex2));
	return callsIndex.size()-1;
}

vector<pair<int, int>> Calls::getCalls(int procIndex1, int procIndex2){
	set<pair<int, int>>* matchingPairs = new set<pair<int, int>>();
	for(vector<pair<int, int>>::iterator it = callsIndex.begin(); it != callsIndex.end(); it++){
		if((it->first == procIndex1 || procIndex1 == ANYVALUE) &&
			(it->second == procIndex2 || procIndex2 == ANYVALUE)){
				matchingPairs->insert(*it);
		}
	}
	return vector<pair<int, int>>(matchingPairs->begin(), matchingPairs->end());
}

vector<pair<int, int>> Calls::getCallsStar(int procIndex1, int procIndex2){
	set<pair<int, int>>* matchingPairs = new set<pair<int, int>>();
	/* future: implement this 
	 */
	return vector<pair<int, int>>(matchingPairs->begin(), matchingPairs->end());
}